package com.wnxy.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 林夕
 * @since 2023-03-18 11:05:47
 */
@RestController
@RequestMapping("/mq")
public class MQController {
    @Autowired
    RabbitTemplate rabbitTemplate;

    @RequestMapping("sendEmail")
    public String sendEmail(String email, String subject, String text){

        Map<String,String> map = new HashMap<>();
        map.put("email",email);
        map.put("subject",subject);
        map.put("text",text);
        rabbitTemplate.convertAndSend("sendEmailExchange","sendEmail",map);

        return "ok";
    }
}
